﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Default.Master" AutoEventWireup="true" CodeBehind="XemDanhSachSanPham.aspx.cs" Inherits="LayoutTemplate.XemDanhSachSanPham" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">

<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<title>Danh sách sản phẩm</title>
<style type="text/css">
.newStyle1 {
	width: 400px;
	height: 300px;
	float: left;
}

.Image 
{
	width: 200px;
	height: 200px;
}

.Link 
{
	width: 200px;
	height: 25px;
}
</style>
    <div><asp:HyperLink ID="HyperLink1" runat="server" 
            NavigateUrl="XemDanhSachSanPham.aspx?DiaPhuong=0">Sản phẩm đang bán trên toàn quốc</asp:HyperLink></div>
    <div><asp:HyperLink ID="HyperLink2" runat="server" 
            NavigateUrl="XemDanhSachSanPham.aspx?DiaPhuong=1">Sản phẩm đang bán trên tp Hồ Chí Minh</asp:HyperLink></div>
    <div><asp:HyperLink ID="HyperLink3" runat="server" 
            NavigateUrl="XemDanhSachSanPham.aspx?DiaPhuong=2">Sản phẩm đang bán tại Hà Nội</asp:HyperLink>    </div>
    <div><asp:HyperLink ID="HyperLink4" runat="server" NavigateUrl="DanhSachSanPhamSapBan.aspx">Sản phẩm sắp bán</asp:HyperLink>    </div>
    <div><asp:HyperLink ID="HyperLink5" runat="server" NavigateUrl="DanhSachSanPhamDaBan.aspx">Sản phẩm đã bán</asp:HyperLink>    </div>
    
<%
    string diaPhuong;
    int id = new int();
    try 
    {
        diaPhuong = Request.QueryString["DiaPhuong"];
        id = int.Parse(diaPhuong);
    }
    catch
    {
        Response.Redirect("XemDanhSachSanPham.aspx?DiaPhuong=0");
    }
    System.Collections.Generic.List<DAO_DTO_WS.DTO.SanPhamDTO> dsSanPham = new System.Collections.Generic.List<DAO_DTO_WS.DTO.SanPhamDTO>();
    //1 tinh trang san pham dang ban
   dsSanPham = DAO_DTO_WS.DAO.SanPhamDAO.layDSSanPham();
   System.Collections.Generic.List<DAO_DTO_WS.DTO.SanPhamDTO> ds = new System.Collections.Generic.List<DAO_DTO_WS.DTO.SanPhamDTO>();
   int countBan = dsSanPham.Count;
    for (int i = 0; i<countBan; ++i)
        {
            if (dsSanPham[i].TinhTrang == 2)
                if (id == 0)
                    ds.Add(dsSanPham[i]);
                else if (dsSanPham[i].MaDiaPhuong == id)
                    ds.Add(dsSanPham[i]);
        }
   int count = ds.Count;
   	 for (int i = 0; i < count; ++i)
    {%>
	<div class="newStyle1">
		<div><img class="Image" src="Images/banh%20bo.jpg" />
        </div>
		<% Response.Write("<div><a href=\"XemChiTietSanPham.aspx?id="
         + ds[i].MaSanPham.ToString() + "\">Xem chi tiet</a></div>"); 
		%>
	</div>
	<%} %>
	
</asp:Content>

